#include<iostream>
#include<fstream>
#include"BinarySearchTree.h"

using namespace std;

int main(int argc, char const *argv[])
{
    /* code */
    BinarySearchTree<int> *binarySearchTree = new BinarySearchTree<int>;
    fstream file;
    file.open("BinarySearchTree.txt",ios::in);

    int i = 1;
    while(!file.eof())
    {
        int temp;
        
        
        file>>temp;
        cout<<i<<":"<<temp<<endl;

        i++;
        binarySearchTree->insertNode(temp);
    }
    cout<<"root:"<<binarySearchTree->root->value<<endl;
    //cout<<"1"<<endl;
    cout<<"PreOrderSearch"<<endl;
    binarySearchTree->preOrderSearch(binarySearchTree->root);
    cout<<"Delele 200"<<endl;
    binarySearchTree->deleteNode(200,true);
    cout<<"PreOrderSearch"<<endl;
    binarySearchTree->preOrderSearch(binarySearchTree->root);
    
    
    cout<<"Delele 100"<<endl;
    binarySearchTree->deleteNode(100,false);
    cout<<"PreOrderSearch"<<endl;
    binarySearchTree->preOrderSearch(binarySearchTree->root);
    cout<<"root:"<<binarySearchTree->root->value<<endl;
    //cout<<"2"<<endl;
    binarySearchTree->preOrderSearch(binarySearchTree->root);

    delete binarySearchTree;
    return 0;
}
